#pragma once

#include <WinReg.h>

class Regedit
{
public:
	Regedit(HKEY hKey = HKEY_CURRENT_USER);
	~Regedit(void);
public:
	int CreateKey(LPCTSTR lpKeyName, LPCTSTR lpVal, int len);
	int CreateKey(LPCTSTR lpKeyName, DWORD dwVal);
	int CreateKey(LPCTSTR lpKeyName, LPCTSTR subKey, LPCTSTR lpVal, int len);
	int CreateKey(LPCTSTR lpKeyName, LPCTSTR subKey, DWORD dwVal);

	int Read(LPCTSTR lpKeyName, CString* lpVal);
	int Read(LPCTSTR lpKeyName, LPCTSTR subKey, CString* lpVal);
	int Read(LPCTSTR lpKeyName, LPCTSTR subKey, DWORD* pdwVal);

	int Write(LPCTSTR lpKeyName, LPCTSTR lpVal, int len);
	int Write(LPCTSTR lpKeyName, DWORD dwVal);
	int Write(LPCTSTR lpKeyName, LPCTSTR subKey, LPCTSTR lpVal, int len);
	int Write(LPCTSTR lpKeyName, LPCTSTR subKey, DWORD dwVal);

	int DeleteKey(LPCTSTR lpKeyName);

	int ListAllItem(LPCTSTR lpKeyName);

	int Open(LPCTSTR lpKeyName);
	void Close();
private:
	HKEY m_hKey;
};

